<?php

namespace App\Providers;

use App\Events\CommissionEvent;
use App\Events\DefaultCommissionEvent;
use App\Events\DiviceAccountEvent;
use App\Events\UpdateUserEvent;
use App\Listeners\CommissionListener;
use App\Listeners\DefaultCommissionListener;
use App\Listeners\DiviceAccountNotifyListener;
use App\Listeners\PayIntegralListener;
use App\Listeners\UpdateUserListener;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
//use Illuminate\Support\Facades\Event;
use Hhxsv5\LaravelS\Swoole\Task\Event;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event to listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        CommissionEvent::class=>[
            CommissionListener::class,
        ],
        DefaultCommissionEvent::class=>[
          DefaultCommissionListener::class,
//          PayIntegralListener::class
        ],
        DiviceAccountEvent::class=>[
            DiviceAccountNotifyListener::class
        ],
        UpdateUserEvent::class=>[
            UpdateUserListener::class
        ]
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        //
//        Event::listen('laravels.received_request', function (\Illuminate\Http\Request $req, $app) {
//            $req->query->set('socket_key', 'hhxsv5');// 修改querystring
//            $req->request->set('sccket_value', 'hhxsv5'); // 修改post body
//        });
//        Event::listen('laravels.generated_response', function (\Illuminate\Http\Request $req, \Symfony\Component\HttpFoundation\Response $rsp, $app) {
//            $rsp->headers->set('header-key', 'hhxsv5');// 修改header
//        });
    }

    /**
     * Determine if events and listeners should be automatically discovered.
     *
     * @return bool
     */
    public function shouldDiscoverEvents()
    {
        return false;
    }
}
